<?php
/**
 * @property ParamFdk $ParamFdk 
 */
class ParamFdksController extends AppController {

	var $name = 'ParamFdks';
	var $helpers = array('Js');

  /**
   * INDEX
   */
	function index() {
		$this->ParamFdk->recursive = 0;
		$this->set('paramFdks', $this->paginate());
	}

  /**
   * VIEW
   * @param type $id 
   */
	function view($id = null) {
		if (!$id) {
			$this->Session->setFlash(__('Invalid param fdk', true));
			$this->redirect(array('action' => 'index'));
		}
		$this->set('paramFdk', $this->ParamFdk->read(null, $id));
	}

  /**
   * ADD
   */
	function add() {
    
		if (!empty($this->data)) {
			$this->ParamFdk->create();
			if ($this->ParamFdk->save($this->data)) {
				$this->Session->setFlash(__('The param fdk has been saved', true));
				$this->redirect(array('action' => 'index'));
			} else {
				$this->Session->setFlash(__('The param fdk could not be saved. Please, try again.', true));
			}
		}
		$paramFdkBases = $this->ParamFdk->ParamFdkBasis->find('list');
		$jobs = $this->ParamFdk->JobVersion->find('list');
		$this->set(compact('paramFdkBases', 'jobs'));
	} ////////////////////////

  /**
   * EDIT
   * @param type $id 
   */
	function edit($id = null) {
    
		if (!$id && empty($this->data)) {
			$this->Session->setFlash(__('Invalid param fdk', true));
			$this->redirect(array('action' => 'index'));
		}
		if (!empty($this->data)) {
			if ($this->ParamFdk->save($this->data)) {
				$this->Session->setFlash(__('The param fdk has been saved', true));
				$this->redirect(array('action' => 'index'));
			} else {
				$this->Session->setFlash(__('The param fdk could not be saved. Please, try again.', true));
			}
		}
    //////////////////////////////
    //// New Edit Screen /////////
		if (empty($this->data)) {
			$this->data = $this->ParamFdk->read(null, $id);
		}
		$paramFdkBases = $this->ParamFdk->ParamFdkBasis->find('list');
		$jobs = $this->ParamFdk->JobVersion->find('list');
		$this->set(compact('paramFdkBases', 'jobs'));
	} //////////////////////////////

  /**
   * DELETE
   * @param type $id 
   */
	function delete($id = null) {
		if (!$id) {
			$this->Session->setFlash(__('Invalid id for param fdk', true));
			$this->redirect(array('action'=>'index'));
		}
		if ($this->ParamFdk->delete($id)) {
			$this->Session->setFlash(__('Param fdk deleted', true));
			$this->redirect(array('action'=>'index'));
		}
		$this->Session->setFlash(__('Param fdk was not deleted', true));
		$this->redirect(array('action' => 'index'));
	}
}
